package com.xinqi.modules.third.controller;


import com.xinqi.common.base.response.R;
import com.xinqi.common.core.web.controller.BaseController;
import com.xinqi.modules.third.service.SmsService;
import com.xinqi.modules.third.sms.dto.req.SendSmsCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;

/**
 * 短信功能
 *
 * @author dgyu
 */
@Slf4j
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/sms")
public class SysSmsController extends BaseController {

    private final SmsService smsService;

    /**
     * 短信验证码
     * @param phonenumber 用户手机号
     */
    @GetMapping("/code")
    public R<String> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber, @NotBlank(message = "{sms.template.not.blank}") String event) {
        return smsService.smsCode(phonenumber, event);
    }

    /**
     * 滑动图片验证码
     * @author: dzy
     * @date: 2023/8/29 14:48
     */
    @PostMapping("/code")
    public R<String> smsCaptcha(@Validated @RequestBody SendSmsCode dto) {
        return smsService.smsCaptcha(dto);
    }

}
